﻿using System;
using System.Collections.Generic;

namespace Cos.Core.Model.Content
{
    public class Page : DomainModelBase
    {
        public int NavId { get; set; }

        // public int ParentNavId { get; set; }

        // public int TemplateId { get; set; }

        public int PageId { get; set; }

        public string PageName { get; set; }

        public string PageNamePreview { get; set; }
        
        public string CultureCode { get; set; }

        public bool PageNavEnd { get; set; }

        public DateTime? CreationDate { get; set; }

        public DateTime? LastModified { get; set; }

        public string Author { get; set; }

        public DateTime? ApprobationDate { get; set; }

        // public IEnumerable<Element> Elements { get; set; }

        public string PageStatus { get; set; }

        public bool PageVisibility { get; set; }

        public bool PageVisibilityPreview { get; set; }

        // public bool HasChildren { get; set; }

        /**
         * Is this page visible
         * 
         * @param isLive should the method return the value for live or preview
         * @return true if the page is visible, false if it isn't
         */
        public bool IsVisible(bool isLive)
        {
            if (!"Approved".Equals(PageStatus) && !"Pending".Equals(PageStatus))
            {
                return false;
            }

            return isLive ? this.PageVisibility : this.PageVisibilityPreview;
        }
    }
}